#include "StdAfx.h"
#include "bllLine.h"


bllLine::bllLine(POINT s, POINT e)
{
	m_start = s;
	m_end = e;
}


bllLine::~bllLine(void)
{
}


bool bllLine::isCross(bllLine line)
{
	float k1 = (m_start.y-m_end.y)/(float)(m_start.x-m_end.x);
	float k2 = (line.m_start.y-line.m_end.y)/(float)(line.m_start.x-line.m_end.x);
	if(k1 == k2)
	{
		return false;
	}
	else
	{
		float c2 = line.m_start.y-k2*line.m_start.x;
		float c1 = m_start.y-k1*m_start.x;
		float x1 = (c2-c1)/(k1-k2);
		float y1 = (c2-c1)/(1-k1/k2)+c1;
		if(x1<line.m_start.x&&x1>line.m_end.x&&y1<line.m_start.y&&y1>line.m_end.y)
			return true;
		else if(x1>line.m_start.x&&x1<line.m_end.x&&y1>line.m_start.y&&y1<line.m_end.y)
			return true;
		else
			return false;
	}
}